package com.smsclient.controller;

import com.smsclient.model.OrgTemplateActiveVo;
import com.smsclient.model.OrgTemplateQueryVo;
import com.smsclient.model.entity.SmsOrgTemplate;
import com.smsclient.response.Response;
import com.smsclient.service.SmsOrgTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping(value = "/SMSTemplate")
@Api(value = "/SMSTemplate", description = "短信模板接口api")
public class SMSTemplateApiController {

    @Autowired
    private SmsOrgTemplateService SmsOrgTemplateService;


    @PostMapping(value = "/listTamplate")
    @ApiOperation(value = "输入公司名称/编号 获取 短信模板",notes = "输入公司名称/编号 获取 短信模板")
    public Response listTamplate(@RequestBody(required = false) OrgTemplateQueryVo vo) throws Exception {
        return Response.succeed(SmsOrgTemplateService.listTamplate(vo));
    }

    @PostMapping(value = "/saveTemplate")
    @ApiOperation(value = "新增/修改短信模板",notes = "新增/修改短信模板")
    public Response saveTemplate(@RequestBody SmsOrgTemplate SmsOrgTemplate) throws Exception {
        SmsOrgTemplateService.saveOrgTemplate(SmsOrgTemplate);
        return Response.succeed("success");
    }

    @PostMapping(value = "/activeTemplate")
    @ApiOperation(value = "激活/禁用短信模板",notes = "激活/禁用短信模板")
    public Response activeTemplate(@RequestBody OrgTemplateActiveVo activeVo) throws Exception {
        activeVo = SmsOrgTemplateService.activeTemplateStatus(activeVo);
        return Response.succeed(activeVo);
    }




}
